package com.qwiki.test

object Trimtest {
  def trim(strings: Array[String]): Array[String] = {
    strings.map(_.trim)
  }

  def javatrim(strings: Array[String]): Array[String] = Test.trim(strings)

  def main(args: Array[String]) {
    val strings: Array[String] = new Array[String](5000);
    for(x:Int <- 0 until strings.length) {
      strings(x) = " a " + x + " "
    }

    var i: Int = 10000;

    while (i > 0) {
      trim(strings)
      Test.trim(strings)
      i = i - 1
    }
    Test.test(strings, 10000)
    // warming up end


    var
    t0 = System.currentTimeMillis()
    i = 10000;
    while (i > 0) {
      trim(strings)
      i = i - 1
    }
    println(System.currentTimeMillis() - t0)
    t0 = System.currentTimeMillis()
    i = 10000;
    while (i > 0) {
      Test.trim(strings)
      i = i - 1
    }
    println(System.currentTimeMillis() - t0)

    t0 = System.currentTimeMillis()
    i = 10000;
    while (i > 0) {
      javatrim(strings)
      i = i - 1
    }
    println(System.currentTimeMillis() - t0)
    t0 = System.currentTimeMillis()
    i = 10000;
    while (i > 0) {
      trim(strings)
      i = i - 1
    }
    println(System.currentTimeMillis() - t0)

    t0 = System.currentTimeMillis()
    i = 10000;
    while (i > 0) {
      Test.trim(strings)
      i = i - 1
    }
    println(System.currentTimeMillis() - t0)
    t0 = System.currentTimeMillis()
    i = 10000;
    while (i > 0) {
      trim(strings)
      i = i - 1
    }
    println(System.currentTimeMillis() - t0)

    t0 = System.currentTimeMillis()
    i = 10000;
    while (i > 0) {
      Test.trim(strings)
      i = i - 1
    }
    println(System.currentTimeMillis() - t0)
    t0 = System.currentTimeMillis()
    i = 10000;
    while (i > 0) {
      trim(strings)
      i = i - 1
    }
    println(System.currentTimeMillis() - t0)

    t0 = System.currentTimeMillis()
    i = 10000;
    while (i > 0) {
      Test.trim(strings)
      i = i - 1
    }
    println(System.currentTimeMillis() - t0)
    t0 = System.currentTimeMillis()
    i = 10000;
    while (i > 0) {
      trim(strings)
      i = i - 1
    }
    println(System.currentTimeMillis() - t0)

    t0 = System.currentTimeMillis()
    i = 10000;
    for(x <- 0 until i) {
      trim(strings)
    }
    println("scala for" + (System.currentTimeMillis() - t0))

    Test.test(strings, 10000)
    Test.test(strings, 10000)
    Test.test(strings, 10000)


  }
}
